package cn.abcsys.devops.application.util;
/**
 * Copyright (2017, ) Institute of Software, Chinese Academy of Sciences
 * Copyright (2017, ) Bocloud Co,. Lmt
 */

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author xuyuanjia2017@otcaix.iscsa.ac.cn
 * @date June 2,2017
 * xyj config javaDoc
 */
public class UsefulTools {
    public static String getSimpleCurrentDateTIme(){
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
        return LocalDateTime.now().format(dtf);
    }

    public static String utilDateConverter(Date d){
        String timePattern = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(timePattern);
        String formatedDate;
        if(d == null)
            formatedDate= sdf.format(new Date());
        else
            formatedDate= sdf.format(d);
        System.out.println(formatedDate);
        return formatedDate;
    }

    public static void main(String[] args) {
        UsefulTools.utilDateConverter(null);
    }
}
